package com.zk.shop.service.Impl;

import com.zk.shop.dao.MsgDao;
import com.zk.shop.dao.ReplyDao;
import com.zk.shop.entity.Goods;
import com.zk.shop.entity.Msg;
import com.zk.shop.entity.Reply;
import com.zk.shop.entity.User;
import com.zk.shop.service.ReplyService;
import com.zk.shop.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class ReplyServiceImpl implements ReplyService {
    SqlSession session= SqlSessionFactoryUtil.getSqlSession();
    ReplyDao replyDao = session.getMapper(ReplyDao.class);
    Msg msg = new Msg();
    User user = new User();
    Goods goods = new Goods();
    @Override
    public List<Reply> ReplyGetMsgId(int msgid) {
        List<Reply> replyList = replyDao.ReplyGetMsgId(msgid);
        return replyList;
    }

    @Override
    public int addReply(Reply reply) {
    /*    user.setUserId(6);
        goods.setGoodsId(6);
        msg.setMsgId(6);
        reply.setConTent("fadsfadsf");
        reply.setUser(user);
        reply.setGoods(goods);
        reply.setMsg(msg);*/
        int flag=  replyDao.addReply(reply);
        System.out.println("新增回复内容"+flag);
        session.commit();
        return flag;
    }

    @Override
    public int deleteReply(int replyid) {
        int flag = replyDao.deleteMsg(replyid);
        System.out.println("删除当前回复"+flag);
        session.commit();
        return flag;
    }

    @Override
    public int deleteReplyByMsgId(int msgid) {
        int flag = replyDao.deleteReplyByMsgId(msgid);
        session.commit();
        return flag;
    }

}
